package com.docmanage.am.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 * 
 * @author ry
 */
@Data
public class FolderTreeSelect implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private Long id;

    /** 节点名称 */
    private String label;

    /** 节点编码 */
    private String code;

    private List<AmFolder> contentList;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<FolderTreeSelect> children;

    public FolderTreeSelect()
    {

    }

    public FolderTreeSelect(AmFolder amFolder)
    {
        this.id = amFolder.getId();
        this.label = amFolder.getName();
        this.code = amFolder.getCode();
        this.children = amFolder.getChildren().stream().map(FolderTreeSelect::new).collect(Collectors.toList());
    }

    public FolderTreeSelect(Object o) {
        AmFolder amFolder = (AmFolder)o;
        this.id = amFolder.getId();
        this.label = amFolder.getName();
        this.code = amFolder.getCode();
        this.children = amFolder.getChildren().stream().map(FolderTreeSelect::new).collect(Collectors.toList());
    }


}
